/*
 * @Author: Your name
 * @Date:   2020-07-23 13:22:02
 * @Last Modified by:   Your name
 * @Last Modified time: 2020-07-23 14:01:13
 */
let app = {
  formIsNullcheck: async function(username, password, confirmPassword, ctx){
    if(username.length == 0){
      await ctx.render('admin/error', {
        message: '用户名不能为空',
        redirect: ctx.state.__HOST__ + '/admin/manage/add'
      });
      return;
    }
    if(password.length == 0){
      await ctx.render('admin/error', {
        message: '密码不能为空',
        redirect: ctx.state.__HOST__ + '/admin/manage/add'
      });
      return;
    }
    if(confirmPassword.length.length == 0){
      await ctx.render('admin/error', {
        message: '确认密码不能为空',
        redirect: ctx.state.__HOST__ + '/admin/manage/add'
      });
      return;
    }
  },
  //密码用户名是否合法的校验
  isErrorCheck: async function(username, password, confirmPassword, ctx){
    if(password.length < 6){
      await ctx.render('admin/error', {
        message: '密码不少于六位',
        redirect: ctx.state.__HOST__ + '/admin/manage/add'
      });
      return ;
    }
    if(password !== confirmPassword){
      await ctx.render('admin/error', {
        message: '两次密码不一致',
        redirect: ctx.state.__HOST__ + '/admin/manage/add'
      });
      return ;
    }
  }
}

module.exports = app;
